

<!DOCTYPE html>
<html class="writer-html5" lang="en" >
<head>
  <meta charset="utf-8" />
  
  <meta name="viewport" content="width=device-width, initial-scale=1.0" />
  
  <title>yubihsm.defs &mdash; python-yubihsm 2.1.0 documentation</title>
  

  
  <link rel="stylesheet" href="../../_static/css/theme.css" type="text/css" />
  <link rel="stylesheet" href="../../_static/pygments.css" type="text/css" />

  
  
    <link rel="shortcut icon" href="../../_static/favicon.ico"/>
  

  
  

  

  
  <!--[if lt IE 9]>
    <script src="../../_static/js/html5shiv.min.js"></script>
  <![endif]-->
  
    
      <script type="text/javascript" id="documentation_options" data-url_root="../../" src="../../_static/documentation_options.js"></script>
        <script src="../../_static/jquery.js"></script>
        <script src="../../_static/underscore.js"></script>
        <script src="../../_static/doctools.js"></script>
    
    <script type="text/javascript" src="../../_static/js/theme.js"></script>

    
    <link rel="index" title="Index" href="../../genindex.html" />
    <link rel="search" title="Search" href="../../search.html" /> 
</head>

<body class="wy-body-for-nav">

   
  <div class="wy-grid-for-nav">
    
    <nav data-toggle="wy-nav-shift" class="wy-nav-side">
      <div class="wy-side-scroll">
        <div class="wy-side-nav-search" >
          

          
            <a href="../../index.html" class="icon icon-home"> python-yubihsm
          

          
          </a>

          
            
            
              <div class="version">
                2.1
              </div>
            
          

          
<div role="search">
  <form id="rtd-search-form" class="wy-form" action="../../search.html" method="get">
    <input type="text" name="q" placeholder="Search docs" />
    <input type="hidden" name="check_keywords" value="yes" />
    <input type="hidden" name="area" value="default" />
  </form>
</div>

          
        </div>

        
        <div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="main navigation">
          
            
            
              
            
            
              <!-- Local TOC -->
              <div class="local-toc"></div>
            
          
        </div>
        
      </div>
    </nav>

    <section data-toggle="wy-nav-shift" class="wy-nav-content-wrap">

      
      <nav class="wy-nav-top" aria-label="top navigation">
        
          <i data-toggle="wy-nav-top" class="fa fa-bars"></i>
          <a href="../../index.html">python-yubihsm</a>
        
      </nav>


      <div class="wy-nav-content">
        
        <div class="rst-content">
        
          

















<div role="navigation" aria-label="breadcrumbs navigation">

  <ul class="wy-breadcrumbs">
    
      <li><a href="../../index.html" class="icon icon-home"></a> &raquo;</li>
        
          <li><a href="../index.html">Module code</a> &raquo;</li>
        
      <li>yubihsm.defs</li>
    
    
      <li class="wy-breadcrumbs-aside">
        
      </li>
    
  </ul>

  
  <hr/>
</div>
          <div role="main" class="document" itemscope="itemscope" itemtype="http://schema.org/Article">
           <div itemprop="articleBody">
            
  <h1>Source code for yubihsm.defs</h1><div class="highlight"><pre>
<span></span><span class="c1"># Copyright 2016-2018 Yubico AB</span>
<span class="c1">#</span>
<span class="c1"># Licensed under the Apache License, Version 2.0 (the &quot;License&quot;);</span>
<span class="c1"># you may not use this file except in compliance with the License.</span>
<span class="c1"># You may obtain a copy of the License at</span>
<span class="c1">#</span>
<span class="c1">#     http://www.apache.org/licenses/LICENSE-2.0</span>
<span class="c1">#</span>
<span class="c1"># Unless required by applicable law or agreed to in writing, software</span>
<span class="c1"># distributed under the License is distributed on an &quot;AS IS&quot; BASIS,</span>
<span class="c1"># WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.</span>
<span class="c1"># See the License for the specific language governing permissions and</span>
<span class="c1"># limitations under the License.</span>

<span class="sd">&quot;&quot;&quot;Named constants used in YubiHSM commands.&quot;&quot;&quot;</span>


<span class="kn">from</span> <span class="nn">__future__</span> <span class="kn">import</span> <span class="n">absolute_import</span><span class="p">,</span> <span class="n">division</span>

<span class="kn">from</span> <span class="nn">cryptography.hazmat.primitives.asymmetric</span> <span class="kn">import</span> <span class="n">ec</span>
<span class="kn">from</span> <span class="nn">cryptography</span> <span class="kn">import</span> <span class="n">utils</span>
<span class="kn">from</span> <span class="nn">enum</span> <span class="kn">import</span> <span class="n">IntEnum</span><span class="p">,</span> <span class="n">unique</span>
<span class="kn">import</span> <span class="nn">six</span>


<span class="k">if</span> <span class="n">six</span><span class="o">.</span><span class="n">PY2</span><span class="p">:</span>
    <span class="c1"># Workaround for int max size on Python 2.</span>
    <span class="kn">from</span> <span class="nn">enum</span> <span class="kn">import</span> <span class="n">Enum</span>

    <span class="k">class</span> <span class="nc">_LongEnum</span><span class="p">(</span><span class="n">long</span><span class="p">,</span> <span class="n">Enum</span><span class="p">):</span>  <span class="c1"># noqa F821</span>
        <span class="sd">&quot;&quot;&quot;Like IntEnum, but supports larger values&quot;&quot;&quot;</span>

    <span class="n">IntEnum</span> <span class="o">=</span> <span class="n">_LongEnum</span>  <span class="c1"># Use instead of IntEnum  # noqa F811</span>


<div class="viewcode-block" id="BRAINPOOLP256R1"><a class="viewcode-back" href="../../rst/yubihsm.html#yubihsm.defs.BRAINPOOLP256R1">[docs]</a><span class="nd">@utils</span><span class="o">.</span><span class="n">register_interface</span><span class="p">(</span><span class="n">ec</span><span class="o">.</span><span class="n">EllipticCurve</span><span class="p">)</span>
<span class="k">class</span> <span class="nc">BRAINPOOLP256R1</span><span class="p">(</span><span class="nb">object</span><span class="p">):</span>
    <span class="n">name</span> <span class="o">=</span> <span class="s2">&quot;brainpoolP256r1&quot;</span>
    <span class="n">key_size</span> <span class="o">=</span> <span class="mi">256</span></div>


<div class="viewcode-block" id="BRAINPOOLP384R1"><a class="viewcode-back" href="../../rst/yubihsm.html#yubihsm.defs.BRAINPOOLP384R1">[docs]</a><span class="nd">@utils</span><span class="o">.</span><span class="n">register_interface</span><span class="p">(</span><span class="n">ec</span><span class="o">.</span><span class="n">EllipticCurve</span><span class="p">)</span>
<span class="k">class</span> <span class="nc">BRAINPOOLP384R1</span><span class="p">(</span><span class="nb">object</span><span class="p">):</span>
    <span class="n">name</span> <span class="o">=</span> <span class="s2">&quot;brainpoolP384r1&quot;</span>
    <span class="n">key_size</span> <span class="o">=</span> <span class="mi">384</span></div>


<div class="viewcode-block" id="BRAINPOOLP512R1"><a class="viewcode-back" href="../../rst/yubihsm.html#yubihsm.defs.BRAINPOOLP512R1">[docs]</a><span class="nd">@utils</span><span class="o">.</span><span class="n">register_interface</span><span class="p">(</span><span class="n">ec</span><span class="o">.</span><span class="n">EllipticCurve</span><span class="p">)</span>
<span class="k">class</span> <span class="nc">BRAINPOOLP512R1</span><span class="p">(</span><span class="nb">object</span><span class="p">):</span>
    <span class="n">name</span> <span class="o">=</span> <span class="s2">&quot;brainpoolP512r1&quot;</span>
    <span class="n">key_size</span> <span class="o">=</span> <span class="mi">512</span></div>


<div class="viewcode-block" id="ERROR"><a class="viewcode-back" href="../../rst/yubihsm.html#yubihsm.defs.ERROR">[docs]</a><span class="nd">@unique</span>
<span class="k">class</span> <span class="nc">ERROR</span><span class="p">(</span><span class="n">IntEnum</span><span class="p">):</span>
    <span class="sd">&quot;&quot;&quot;Error codes returned by the YubiHSM&quot;&quot;&quot;</span>

    <span class="n">OK</span> <span class="o">=</span> <span class="mh">0x00</span>
    <span class="n">INVALID_COMMAND</span> <span class="o">=</span> <span class="mh">0x01</span>
    <span class="n">INVALID_DATA</span> <span class="o">=</span> <span class="mh">0x02</span>
    <span class="n">INVALID_SESSION</span> <span class="o">=</span> <span class="mh">0x03</span>
    <span class="n">AUTHENTICATION_FAILED</span> <span class="o">=</span> <span class="mh">0x04</span>
    <span class="n">SESSIONS_FULL</span> <span class="o">=</span> <span class="mh">0x05</span>
    <span class="n">SESSION_FAILED</span> <span class="o">=</span> <span class="mh">0x06</span>
    <span class="n">STORAGE_FAILED</span> <span class="o">=</span> <span class="mh">0x07</span>
    <span class="n">WRONG_LENGTH</span> <span class="o">=</span> <span class="mh">0x08</span>
    <span class="n">INSUFFICIENT_PERMISSIONS</span> <span class="o">=</span> <span class="mh">0x09</span>
    <span class="n">LOG_FULL</span> <span class="o">=</span> <span class="mh">0x0A</span>
    <span class="n">OBJECT_NOT_FOUND</span> <span class="o">=</span> <span class="mh">0x0B</span>
    <span class="n">INVALID_ID</span> <span class="o">=</span> <span class="mh">0x0C</span>
    <span class="n">SSH_CA_CONSTRAINT_VIOLATION</span> <span class="o">=</span> <span class="mh">0x0E</span>
    <span class="n">INVALID_OTP</span> <span class="o">=</span> <span class="mh">0x0F</span>
    <span class="n">DEMO_MODE</span> <span class="o">=</span> <span class="mh">0x10</span>
    <span class="n">OBJECT_EXISTS</span> <span class="o">=</span> <span class="mh">0x11</span>
    <span class="n">COMMAND_UNEXECUTED</span> <span class="o">=</span> <span class="mh">0xFF</span></div>


<div class="viewcode-block" id="COMMAND"><a class="viewcode-back" href="../../rst/yubihsm.html#yubihsm.defs.COMMAND">[docs]</a><span class="nd">@unique</span>
<span class="k">class</span> <span class="nc">COMMAND</span><span class="p">(</span><span class="n">IntEnum</span><span class="p">):</span>
    <span class="sd">&quot;&quot;&quot;Commands available to send to the YubiHSM&quot;&quot;&quot;</span>

    <span class="n">ECHO</span> <span class="o">=</span> <span class="mh">0x01</span>
    <span class="n">CREATE_SESSION</span> <span class="o">=</span> <span class="mh">0x03</span>
    <span class="n">AUTHENTICATE_SESSION</span> <span class="o">=</span> <span class="mh">0x04</span>
    <span class="n">SESSION_MESSAGE</span> <span class="o">=</span> <span class="mh">0x05</span>
    <span class="n">DEVICE_INFO</span> <span class="o">=</span> <span class="mh">0x06</span>
    <span class="n">RESET_DEVICE</span> <span class="o">=</span> <span class="mh">0x08</span>
    <span class="n">CLOSE_SESSION</span> <span class="o">=</span> <span class="mh">0x40</span>
    <span class="n">GET_STORAGE_INFO</span> <span class="o">=</span> <span class="mh">0x041</span>
    <span class="n">PUT_OPAQUE</span> <span class="o">=</span> <span class="mh">0x42</span>
    <span class="n">GET_OPAQUE</span> <span class="o">=</span> <span class="mh">0x43</span>
    <span class="n">PUT_AUTHENTICATION_KEY</span> <span class="o">=</span> <span class="mh">0x44</span>
    <span class="n">PUT_ASYMMETRIC_KEY</span> <span class="o">=</span> <span class="mh">0x45</span>
    <span class="n">GENERATE_ASYMMETRIC_KEY</span> <span class="o">=</span> <span class="mh">0x46</span>
    <span class="n">SIGN_PKCS1</span> <span class="o">=</span> <span class="mh">0x47</span>
    <span class="n">LIST_OBJECTS</span> <span class="o">=</span> <span class="mh">0x48</span>
    <span class="n">DECRYPT_PKCS1</span> <span class="o">=</span> <span class="mh">0x49</span>
    <span class="n">EXPORT_WRAPPED</span> <span class="o">=</span> <span class="mh">0x4A</span>
    <span class="n">IMPORT_WRAPPED</span> <span class="o">=</span> <span class="mh">0x4B</span>
    <span class="n">PUT_WRAP_KEY</span> <span class="o">=</span> <span class="mh">0x4C</span>
    <span class="n">GET_LOG_ENTRIES</span> <span class="o">=</span> <span class="mh">0x4D</span>
    <span class="n">GET_OBJECT_INFO</span> <span class="o">=</span> <span class="mh">0x4E</span>
    <span class="n">SET_OPTION</span> <span class="o">=</span> <span class="mh">0x4F</span>
    <span class="n">GET_OPTION</span> <span class="o">=</span> <span class="mh">0x50</span>
    <span class="n">GET_PSEUDO_RANDOM</span> <span class="o">=</span> <span class="mh">0x51</span>
    <span class="n">PUT_HMAC_KEY</span> <span class="o">=</span> <span class="mh">0x52</span>
    <span class="n">SIGN_HMAC</span> <span class="o">=</span> <span class="mh">0x53</span>
    <span class="n">GET_PUBLIC_KEY</span> <span class="o">=</span> <span class="mh">0x54</span>
    <span class="n">SIGN_PSS</span> <span class="o">=</span> <span class="mh">0x55</span>
    <span class="n">SIGN_ECDSA</span> <span class="o">=</span> <span class="mh">0x56</span>
    <span class="n">DERIVE_ECDH</span> <span class="o">=</span> <span class="mh">0x57</span>
    <span class="n">DELETE_OBJECT</span> <span class="o">=</span> <span class="mh">0x58</span>
    <span class="n">DECRYPT_OAEP</span> <span class="o">=</span> <span class="mh">0x59</span>
    <span class="n">GENERATE_HMAC_KEY</span> <span class="o">=</span> <span class="mh">0x5A</span>
    <span class="n">GENERATE_WRAP_KEY</span> <span class="o">=</span> <span class="mh">0x5B</span>
    <span class="n">VERIFY_HMAC</span> <span class="o">=</span> <span class="mh">0x5C</span>
    <span class="n">SIGN_SSH_CERTIFICATE</span> <span class="o">=</span> <span class="mh">0x5D</span>
    <span class="n">PUT_TEMPLATE</span> <span class="o">=</span> <span class="mh">0x5E</span>
    <span class="n">GET_TEMPLATE</span> <span class="o">=</span> <span class="mh">0x5F</span>
    <span class="n">DECRYPT_OTP</span> <span class="o">=</span> <span class="mh">0x60</span>
    <span class="n">CREATE_OTP_AEAD</span> <span class="o">=</span> <span class="mh">0x61</span>
    <span class="n">RANDOMIZE_OTP_AEAD</span> <span class="o">=</span> <span class="mh">0x62</span>
    <span class="n">REWRAP_OTP_AEAD</span> <span class="o">=</span> <span class="mh">0x63</span>
    <span class="n">SIGN_ATTESTATION_CERTIFICATE</span> <span class="o">=</span> <span class="mh">0x64</span>
    <span class="n">PUT_OTP_AEAD_KEY</span> <span class="o">=</span> <span class="mh">0x65</span>
    <span class="n">GENERATE_OTP_AEAD_KEY</span> <span class="o">=</span> <span class="mh">0x66</span>
    <span class="n">SET_LOG_INDEX</span> <span class="o">=</span> <span class="mh">0x67</span>
    <span class="n">WRAP_DATA</span> <span class="o">=</span> <span class="mh">0x68</span>
    <span class="n">UNWRAP_DATA</span> <span class="o">=</span> <span class="mh">0x69</span>
    <span class="n">SIGN_EDDSA</span> <span class="o">=</span> <span class="mh">0x6A</span>
    <span class="n">BLINK_DEVICE</span> <span class="o">=</span> <span class="mh">0x6B</span>
    <span class="n">CHANGE_AUTHENTICATION_KEY</span> <span class="o">=</span> <span class="mh">0x6C</span>

    <span class="n">ERROR</span> <span class="o">=</span> <span class="mh">0x7F</span></div>


<div class="viewcode-block" id="ALGORITHM"><a class="viewcode-back" href="../../rst/yubihsm.html#yubihsm.defs.ALGORITHM">[docs]</a><span class="nd">@unique</span>
<span class="k">class</span> <span class="nc">ALGORITHM</span><span class="p">(</span><span class="n">IntEnum</span><span class="p">):</span>
    <span class="sd">&quot;&quot;&quot;Various algorithm constants&quot;&quot;&quot;</span>

    <span class="n">RSA_PKCS1_SHA1</span> <span class="o">=</span> <span class="mi">1</span>
    <span class="n">RSA_PKCS1_SHA256</span> <span class="o">=</span> <span class="mi">2</span>
    <span class="n">RSA_PKCS1_SHA384</span> <span class="o">=</span> <span class="mi">3</span>
    <span class="n">RSA_PKCS1_SHA512</span> <span class="o">=</span> <span class="mi">4</span>
    <span class="n">RSA_PSS_SHA1</span> <span class="o">=</span> <span class="mi">5</span>
    <span class="n">RSA_PSS_SHA256</span> <span class="o">=</span> <span class="mi">6</span>
    <span class="n">RSA_PSS_SHA384</span> <span class="o">=</span> <span class="mi">7</span>
    <span class="n">RSA_PSS_SHA512</span> <span class="o">=</span> <span class="mi">8</span>
    <span class="n">RSA_2048</span> <span class="o">=</span> <span class="mi">9</span>
    <span class="n">RSA_3072</span> <span class="o">=</span> <span class="mi">10</span>
    <span class="n">RSA_4096</span> <span class="o">=</span> <span class="mi">11</span>
    <span class="n">RSA_OAEP_SHA1</span> <span class="o">=</span> <span class="mi">25</span>
    <span class="n">RSA_OAEP_SHA256</span> <span class="o">=</span> <span class="mi">26</span>
    <span class="n">RSA_OAEP_SHA384</span> <span class="o">=</span> <span class="mi">27</span>
    <span class="n">RSA_OAEP_SHA512</span> <span class="o">=</span> <span class="mi">28</span>
    <span class="n">RSA_MGF1_SHA1</span> <span class="o">=</span> <span class="mi">32</span>
    <span class="n">RSA_MGF1_SHA256</span> <span class="o">=</span> <span class="mi">33</span>
    <span class="n">RSA_MGF1_SHA384</span> <span class="o">=</span> <span class="mi">34</span>
    <span class="n">RSA_MGF1_SHA512</span> <span class="o">=</span> <span class="mi">35</span>

    <span class="n">EC_P256</span> <span class="o">=</span> <span class="mi">12</span>
    <span class="n">EC_P384</span> <span class="o">=</span> <span class="mi">13</span>
    <span class="n">EC_P521</span> <span class="o">=</span> <span class="mi">14</span>
    <span class="n">EC_K256</span> <span class="o">=</span> <span class="mi">15</span>
    <span class="n">EC_BP256</span> <span class="o">=</span> <span class="mi">16</span>
    <span class="n">EC_BP384</span> <span class="o">=</span> <span class="mi">17</span>
    <span class="n">EC_BP512</span> <span class="o">=</span> <span class="mi">18</span>

    <span class="n">EC_ECDSA_SHA1</span> <span class="o">=</span> <span class="mi">23</span>
    <span class="n">EC_ECDH</span> <span class="o">=</span> <span class="mi">24</span>

    <span class="n">HMAC_SHA1</span> <span class="o">=</span> <span class="mi">19</span>
    <span class="n">HMAC_SHA256</span> <span class="o">=</span> <span class="mi">20</span>
    <span class="n">HMAC_SHA384</span> <span class="o">=</span> <span class="mi">21</span>
    <span class="n">HMAC_SHA512</span> <span class="o">=</span> <span class="mi">22</span>

    <span class="n">AES128_CCM_WRAP</span> <span class="o">=</span> <span class="mi">29</span>
    <span class="n">OPAQUE_DATA</span> <span class="o">=</span> <span class="mi">30</span>
    <span class="n">OPAQUE_X509_CERTIFICATE</span> <span class="o">=</span> <span class="mi">31</span>
    <span class="n">TEMPLATE_SSH</span> <span class="o">=</span> <span class="mi">36</span>
    <span class="n">AES128_YUBICO_OTP</span> <span class="o">=</span> <span class="mi">37</span>
    <span class="n">AES128_YUBICO_AUTHENTICATION</span> <span class="o">=</span> <span class="mi">38</span>
    <span class="n">AES192_YUBICO_OTP</span> <span class="o">=</span> <span class="mi">39</span>
    <span class="n">AES256_YUBICO_OTP</span> <span class="o">=</span> <span class="mi">40</span>
    <span class="n">AES192_CCM_WRAP</span> <span class="o">=</span> <span class="mi">41</span>
    <span class="n">AES256_CCM_WRAP</span> <span class="o">=</span> <span class="mi">42</span>
    <span class="n">EC_ECDSA_SHA256</span> <span class="o">=</span> <span class="mi">43</span>
    <span class="n">EC_ECDSA_SHA384</span> <span class="o">=</span> <span class="mi">44</span>
    <span class="n">EC_ECDSA_SHA512</span> <span class="o">=</span> <span class="mi">45</span>
    <span class="n">EC_ED25519</span> <span class="o">=</span> <span class="mi">46</span>
    <span class="n">EC_P224</span> <span class="o">=</span> <span class="mi">47</span>

<div class="viewcode-block" id="ALGORITHM.to_curve"><a class="viewcode-back" href="../../rst/yubihsm.html#yubihsm.defs.ALGORITHM.to_curve">[docs]</a>    <span class="k">def</span> <span class="nf">to_curve</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot;Return a Cryptography EC curve instance for a given member.</span>

<span class="sd">        :return: The corresponding curve.</span>
<span class="sd">        :rtype: cryptography.hazmat.primitives.ec.</span>

<span class="sd">        :Example:</span>

<span class="sd">        &gt;&gt;&gt; isinstance(ALGORITHM.EC_P256.to_curve(), ec.SECP256R1)</span>
<span class="sd">        True</span>
<span class="sd">        &quot;&quot;&quot;</span>

        <span class="k">return</span> <span class="n">_curve_table</span><span class="p">[</span><span class="bp">self</span><span class="p">]()</span></div>

<div class="viewcode-block" id="ALGORITHM.for_curve"><a class="viewcode-back" href="../../rst/yubihsm.html#yubihsm.defs.ALGORITHM.for_curve">[docs]</a>    <span class="nd">@staticmethod</span>
    <span class="k">def</span> <span class="nf">for_curve</span><span class="p">(</span><span class="n">curve</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot;Returns a member corresponding to a Cryptography curve instance.</span>

<span class="sd">        :Example:</span>

<span class="sd">        &gt;&gt;&gt; ALGORITHM.for_curve(ec.SECP256R1()) == ALGORITHM.EC_P256</span>
<span class="sd">        True</span>
<span class="sd">        &quot;&quot;&quot;</span>

        <span class="n">curve_type</span> <span class="o">=</span> <span class="nb">type</span><span class="p">(</span><span class="n">curve</span><span class="p">)</span>
        <span class="k">for</span> <span class="n">key</span><span class="p">,</span> <span class="n">val</span> <span class="ow">in</span> <span class="n">_curve_table</span><span class="o">.</span><span class="n">items</span><span class="p">():</span>
            <span class="k">if</span> <span class="n">val</span> <span class="o">==</span> <span class="n">curve_type</span><span class="p">:</span>
                <span class="k">return</span> <span class="n">key</span>
        <span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span><span class="s2">&quot;Unsupported curve type: </span><span class="si">%s</span><span class="s2">&quot;</span> <span class="o">%</span> <span class="n">curve</span><span class="o">.</span><span class="n">name</span><span class="p">)</span></div></div>


<span class="n">_curve_table</span> <span class="o">=</span> <span class="p">{</span>
    <span class="n">ALGORITHM</span><span class="o">.</span><span class="n">EC_P224</span><span class="p">:</span> <span class="n">ec</span><span class="o">.</span><span class="n">SECP224R1</span><span class="p">,</span>
    <span class="n">ALGORITHM</span><span class="o">.</span><span class="n">EC_P256</span><span class="p">:</span> <span class="n">ec</span><span class="o">.</span><span class="n">SECP256R1</span><span class="p">,</span>
    <span class="n">ALGORITHM</span><span class="o">.</span><span class="n">EC_P384</span><span class="p">:</span> <span class="n">ec</span><span class="o">.</span><span class="n">SECP384R1</span><span class="p">,</span>
    <span class="n">ALGORITHM</span><span class="o">.</span><span class="n">EC_P521</span><span class="p">:</span> <span class="n">ec</span><span class="o">.</span><span class="n">SECP521R1</span><span class="p">,</span>
    <span class="n">ALGORITHM</span><span class="o">.</span><span class="n">EC_K256</span><span class="p">:</span> <span class="n">ec</span><span class="o">.</span><span class="n">SECP256K1</span><span class="p">,</span>
    <span class="n">ALGORITHM</span><span class="o">.</span><span class="n">EC_BP256</span><span class="p">:</span> <span class="n">BRAINPOOLP256R1</span><span class="p">,</span>
    <span class="n">ALGORITHM</span><span class="o">.</span><span class="n">EC_BP384</span><span class="p">:</span> <span class="n">BRAINPOOLP384R1</span><span class="p">,</span>
    <span class="n">ALGORITHM</span><span class="o">.</span><span class="n">EC_BP512</span><span class="p">:</span> <span class="n">BRAINPOOLP512R1</span><span class="p">,</span>
<span class="p">}</span>


<div class="viewcode-block" id="LIST_FILTER"><a class="viewcode-back" href="../../rst/yubihsm.html#yubihsm.defs.LIST_FILTER">[docs]</a><span class="nd">@unique</span>
<span class="k">class</span> <span class="nc">LIST_FILTER</span><span class="p">(</span><span class="n">IntEnum</span><span class="p">):</span>
    <span class="sd">&quot;&quot;&quot;Keys for use to filter on in list_objects&quot;&quot;&quot;</span>

    <span class="n">ID</span> <span class="o">=</span> <span class="mh">0x01</span>
    <span class="n">TYPE</span> <span class="o">=</span> <span class="mh">0x02</span>
    <span class="n">DOMAINS</span> <span class="o">=</span> <span class="mh">0x03</span>
    <span class="n">CAPABILITIES</span> <span class="o">=</span> <span class="mh">0x04</span>
    <span class="n">ALGORITHM</span> <span class="o">=</span> <span class="mh">0x05</span>
    <span class="n">LABEL</span> <span class="o">=</span> <span class="mh">0x06</span></div>


<div class="viewcode-block" id="OBJECT"><a class="viewcode-back" href="../../rst/yubihsm.html#yubihsm.defs.OBJECT">[docs]</a><span class="nd">@unique</span>
<span class="k">class</span> <span class="nc">OBJECT</span><span class="p">(</span><span class="n">IntEnum</span><span class="p">):</span>
    <span class="sd">&quot;&quot;&quot;YubiHSM object types&quot;&quot;&quot;</span>

    <span class="n">OPAQUE</span> <span class="o">=</span> <span class="mh">0x01</span>
    <span class="n">AUTHENTICATION_KEY</span> <span class="o">=</span> <span class="mh">0x02</span>
    <span class="n">ASYMMETRIC_KEY</span> <span class="o">=</span> <span class="mh">0x03</span>
    <span class="n">WRAP_KEY</span> <span class="o">=</span> <span class="mh">0x04</span>
    <span class="n">HMAC_KEY</span> <span class="o">=</span> <span class="mh">0x05</span>
    <span class="n">TEMPLATE</span> <span class="o">=</span> <span class="mh">0x06</span>
    <span class="n">OTP_AEAD_KEY</span> <span class="o">=</span> <span class="mh">0x07</span></div>


<div class="viewcode-block" id="OPTION"><a class="viewcode-back" href="../../rst/yubihsm.html#yubihsm.defs.OPTION">[docs]</a><span class="nd">@unique</span>
<span class="k">class</span> <span class="nc">OPTION</span><span class="p">(</span><span class="n">IntEnum</span><span class="p">):</span>
    <span class="sd">&quot;&quot;&quot;YubiHSM device options&quot;&quot;&quot;</span>

    <span class="n">FORCE_AUDIT</span> <span class="o">=</span> <span class="mh">0x01</span>
    <span class="n">COMMAND_AUDIT</span> <span class="o">=</span> <span class="mh">0x03</span></div>


<div class="viewcode-block" id="AUDIT"><a class="viewcode-back" href="../../rst/yubihsm.html#yubihsm.defs.AUDIT">[docs]</a><span class="nd">@unique</span>
<span class="k">class</span> <span class="nc">AUDIT</span><span class="p">(</span><span class="n">IntEnum</span><span class="p">):</span>
    <span class="sd">&quot;&quot;&quot;Values for audit options&quot;&quot;&quot;</span>

    <span class="n">OFF</span> <span class="o">=</span> <span class="mh">0x00</span>
    <span class="n">ON</span> <span class="o">=</span> <span class="mh">0x01</span>
    <span class="n">FIXED</span> <span class="o">=</span> <span class="mh">0x02</span></div>


<div class="viewcode-block" id="CAPABILITY"><a class="viewcode-back" href="../../rst/yubihsm.html#yubihsm.defs.CAPABILITY">[docs]</a><span class="nd">@unique</span>
<span class="k">class</span> <span class="nc">CAPABILITY</span><span class="p">(</span><span class="n">IntEnum</span><span class="p">):</span>
    <span class="sd">&quot;&quot;&quot;YubiHSM object capability flags&quot;&quot;&quot;</span>

    <span class="n">GET_OPAQUE</span> <span class="o">=</span> <span class="mi">1</span> <span class="o">&lt;&lt;</span> <span class="mh">0x00</span>
    <span class="n">PUT_OPAQUE</span> <span class="o">=</span> <span class="mi">1</span> <span class="o">&lt;&lt;</span> <span class="mh">0x01</span>
    <span class="n">PUT_AUTHENTICATION_KEY</span> <span class="o">=</span> <span class="mi">1</span> <span class="o">&lt;&lt;</span> <span class="mh">0x02</span>
    <span class="n">PUT_ASYMMETRIC</span> <span class="o">=</span> <span class="mi">1</span> <span class="o">&lt;&lt;</span> <span class="mh">0x03</span>
    <span class="n">GENERATE_ASYMMETRIC_KEY</span> <span class="o">=</span> <span class="mi">1</span> <span class="o">&lt;&lt;</span> <span class="mh">0x04</span>
    <span class="n">SIGN_PKCS</span> <span class="o">=</span> <span class="mi">1</span> <span class="o">&lt;&lt;</span> <span class="mh">0x05</span>
    <span class="n">SIGN_PSS</span> <span class="o">=</span> <span class="mi">1</span> <span class="o">&lt;&lt;</span> <span class="mh">0x06</span>
    <span class="n">SIGN_ECDSA</span> <span class="o">=</span> <span class="mi">1</span> <span class="o">&lt;&lt;</span> <span class="mh">0x07</span>
    <span class="n">SIGN_EDDSA</span> <span class="o">=</span> <span class="mi">1</span> <span class="o">&lt;&lt;</span> <span class="mh">0x08</span>
    <span class="n">DECRYPT_PKCS</span> <span class="o">=</span> <span class="mi">1</span> <span class="o">&lt;&lt;</span> <span class="mh">0x09</span>
    <span class="n">DECRYPT_OAEP</span> <span class="o">=</span> <span class="mi">1</span> <span class="o">&lt;&lt;</span> <span class="mh">0x0A</span>
    <span class="n">DERIVE_ECDH</span> <span class="o">=</span> <span class="mi">1</span> <span class="o">&lt;&lt;</span> <span class="mh">0x0B</span>
    <span class="n">EXPORT_WRAPPED</span> <span class="o">=</span> <span class="mi">1</span> <span class="o">&lt;&lt;</span> <span class="mh">0x0C</span>
    <span class="n">IMPORT_WRAPPED</span> <span class="o">=</span> <span class="mi">1</span> <span class="o">&lt;&lt;</span> <span class="mh">0x0D</span>
    <span class="n">PUT_WRAP_KEY</span> <span class="o">=</span> <span class="mi">1</span> <span class="o">&lt;&lt;</span> <span class="mh">0x0E</span>
    <span class="n">GENERATE_WRAP_KEY</span> <span class="o">=</span> <span class="mi">1</span> <span class="o">&lt;&lt;</span> <span class="mh">0x0F</span>
    <span class="n">EXPORTABLE_UNDER_WRAP</span> <span class="o">=</span> <span class="mi">1</span> <span class="o">&lt;&lt;</span> <span class="mh">0x10</span>
    <span class="n">SET_OPTION</span> <span class="o">=</span> <span class="mi">1</span> <span class="o">&lt;&lt;</span> <span class="mh">0x11</span>
    <span class="n">GET_OPTION</span> <span class="o">=</span> <span class="mi">1</span> <span class="o">&lt;&lt;</span> <span class="mh">0x12</span>
    <span class="n">GET_PSEUDO_RANDOM</span> <span class="o">=</span> <span class="mi">1</span> <span class="o">&lt;&lt;</span> <span class="mh">0x13</span>
    <span class="n">PUT_HMAC_KEY</span> <span class="o">=</span> <span class="mi">1</span> <span class="o">&lt;&lt;</span> <span class="mh">0x14</span>
    <span class="n">GENERATE_HMAC_KEY</span> <span class="o">=</span> <span class="mi">1</span> <span class="o">&lt;&lt;</span> <span class="mh">0x15</span>
    <span class="n">SIGN_HMAC</span> <span class="o">=</span> <span class="mi">1</span> <span class="o">&lt;&lt;</span> <span class="mh">0x16</span>
    <span class="n">VERIFY_HMAC</span> <span class="o">=</span> <span class="mi">1</span> <span class="o">&lt;&lt;</span> <span class="mh">0x17</span>
    <span class="n">GET_LOG_ENTRIES</span> <span class="o">=</span> <span class="mi">1</span> <span class="o">&lt;&lt;</span> <span class="mh">0x18</span>
    <span class="n">SIGN_SSH_CERTIFICATE</span> <span class="o">=</span> <span class="mi">1</span> <span class="o">&lt;&lt;</span> <span class="mh">0x19</span>
    <span class="n">GET_TEMPLATE</span> <span class="o">=</span> <span class="mi">1</span> <span class="o">&lt;&lt;</span> <span class="mh">0x1A</span>
    <span class="n">PUT_TEMPLATE</span> <span class="o">=</span> <span class="mi">1</span> <span class="o">&lt;&lt;</span> <span class="mh">0x1B</span>
    <span class="n">RESET_DEVICE</span> <span class="o">=</span> <span class="mi">1</span> <span class="o">&lt;&lt;</span> <span class="mh">0x1C</span>
    <span class="n">DECRYPT_OTP</span> <span class="o">=</span> <span class="mi">1</span> <span class="o">&lt;&lt;</span> <span class="mh">0x1D</span>
    <span class="n">CREATE_OTP_AEAD</span> <span class="o">=</span> <span class="mi">1</span> <span class="o">&lt;&lt;</span> <span class="mh">0x1E</span>
    <span class="n">RANDOMIZE_OTP_AEAD</span> <span class="o">=</span> <span class="mi">1</span> <span class="o">&lt;&lt;</span> <span class="mh">0x1F</span>
    <span class="n">REWRAP_FROM_OTP_AEAD_KEY</span> <span class="o">=</span> <span class="mi">1</span> <span class="o">&lt;&lt;</span> <span class="mh">0x20</span>
    <span class="n">REWRAP_TO_OTP_AEAD_KEY</span> <span class="o">=</span> <span class="mi">1</span> <span class="o">&lt;&lt;</span> <span class="mh">0x21</span>
    <span class="n">SIGN_ATTESTATION_CERTIFICATE</span> <span class="o">=</span> <span class="mi">1</span> <span class="o">&lt;&lt;</span> <span class="mh">0x22</span>
    <span class="n">PUT_OTP_AEAD_KEY</span> <span class="o">=</span> <span class="mi">1</span> <span class="o">&lt;&lt;</span> <span class="mh">0x23</span>
    <span class="n">GENERATE_OTP_AEAD_KEY</span> <span class="o">=</span> <span class="mi">1</span> <span class="o">&lt;&lt;</span> <span class="mh">0x24</span>
    <span class="n">WRAP_DATA</span> <span class="o">=</span> <span class="mi">1</span> <span class="o">&lt;&lt;</span> <span class="mh">0x25</span>
    <span class="n">UNWRAP_DATA</span> <span class="o">=</span> <span class="mi">1</span> <span class="o">&lt;&lt;</span> <span class="mh">0x26</span>
    <span class="n">DELETE_OPAQUE</span> <span class="o">=</span> <span class="mi">1</span> <span class="o">&lt;&lt;</span> <span class="mh">0x27</span>
    <span class="n">DELETE_AUTHENTICATION_KEY</span> <span class="o">=</span> <span class="mi">1</span> <span class="o">&lt;&lt;</span> <span class="mh">0x28</span>
    <span class="n">DELETE_ASYMMETRIC_KEY</span> <span class="o">=</span> <span class="mi">1</span> <span class="o">&lt;&lt;</span> <span class="mh">0x29</span>
    <span class="n">DELETE_WRAP_KEY</span> <span class="o">=</span> <span class="mi">1</span> <span class="o">&lt;&lt;</span> <span class="mh">0x2A</span>
    <span class="n">DELETE_HMAC_KEY</span> <span class="o">=</span> <span class="mi">1</span> <span class="o">&lt;&lt;</span> <span class="mh">0x2B</span>
    <span class="n">DELETE_TEMPLATE</span> <span class="o">=</span> <span class="mi">1</span> <span class="o">&lt;&lt;</span> <span class="mh">0x2C</span>
    <span class="n">DELETE_OTP_AEAD_KEY</span> <span class="o">=</span> <span class="mi">1</span> <span class="o">&lt;&lt;</span> <span class="mh">0x2D</span>
    <span class="n">CHANGE_AUTHENTICATION_KEY</span> <span class="o">=</span> <span class="mi">1</span> <span class="o">&lt;&lt;</span> <span class="mh">0x2E</span></div>


<span class="n">CAPABILITY</span><span class="o">.</span><span class="n">ALL</span> <span class="o">=</span> <span class="nb">sum</span><span class="p">(</span><span class="n">CAPABILITY</span><span class="p">)</span>
<span class="n">CAPABILITY</span><span class="o">.</span><span class="n">NONE</span> <span class="o">=</span> <span class="mh">0x00</span>


<div class="viewcode-block" id="ORIGIN"><a class="viewcode-back" href="../../rst/yubihsm.html#yubihsm.defs.ORIGIN">[docs]</a><span class="k">class</span> <span class="nc">ORIGIN</span><span class="p">(</span><span class="nb">int</span><span class="p">):</span>
    <span class="n">GENERATED</span> <span class="o">=</span> <span class="mh">0x01</span>
    <span class="n">IMPORTED</span> <span class="o">=</span> <span class="mh">0x02</span>
    <span class="n">IMPORTED_WRAPPED</span> <span class="o">=</span> <span class="mh">0x10</span>  <span class="c1"># Used in combination with GENERATED/IMPORTED</span>

    <span class="nd">@property</span>
    <span class="k">def</span> <span class="nf">generated</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
        <span class="k">return</span> <span class="n">ORIGIN</span><span class="o">.</span><span class="n">GENERATED</span> <span class="o">&amp;</span> <span class="bp">self</span> <span class="o">!=</span> <span class="mi">0</span>

    <span class="nd">@property</span>
    <span class="k">def</span> <span class="nf">imported</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
        <span class="k">return</span> <span class="n">ORIGIN</span><span class="o">.</span><span class="n">IMPORTED</span> <span class="o">&amp;</span> <span class="bp">self</span> <span class="o">!=</span> <span class="mi">0</span>

    <span class="nd">@property</span>
    <span class="k">def</span> <span class="nf">wrapped</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
        <span class="k">return</span> <span class="n">ORIGIN</span><span class="o">.</span><span class="n">IMPORTED_WRAPPED</span> <span class="o">&amp;</span> <span class="bp">self</span> <span class="o">!=</span> <span class="mi">0</span></div>
</pre></div>

           </div>
           
          </div>
          <footer>

  <hr/>

  <div role="contentinfo">
    <p>
        &#169; Copyright 2018, Yubico.

    </p>
  </div>
    
    
    
    Built with <a href="https://www.sphinx-doc.org/">Sphinx</a> using a
    
    <a href="https://github.com/readthedocs/sphinx_rtd_theme">theme</a>
    
    provided by <a href="https://readthedocs.org">Read the Docs</a>. 

</footer>
        </div>
      </div>

    </section>

  </div>
  

  <script type="text/javascript">
      jQuery(function () {
          SphinxRtdTheme.Navigation.enable(true);
      });
  </script>

  
  
    
   

</body>
</html>